Current computer users demand more sophisticated graphic display capabilities for computer applications than in previous years. As the field has developed, many methods and innovations have been made to meet these growing user demands. There often is a leap-frogging of development between software capabilities and machine capabilities. Any advance in one or the other may allow for an increase in performance and visual quality which can be balanced against the costs associated with the improvements. Increases in hardware technology, processing speed, and computer memory have made possible increased graphic quality and time to render that heretofore were not acceptable, either in terms of the cost of the hardware required or the inordinate amount of time necessary to render images. Likewise, software developments have also led to improved quality and performance.
Rendering transparent objects has been a particularly difficult problem in computer graphics. In general, rendering opaque objects in a three dimensional scene is accomplished through the use of various algorithms. The z-buffer algorithm is typical.
In the z-buffer algorithm, a frame buffer stores color values for each pixel and a z-buffer stores a depth, or z-value, for each pixel. In the first step, the frame buffer is initialized to the background color and the z-buffer is initialized to O. Second, objects are rasterized and sent to the frame buffer in arbitrary order, usually in the order in which they are encountered from the data received. The z-buffer, having corresponding entries with the frame buffer, stores a z-value for each pixel. The z-value for a pixel indicates whether the pixel of an object is in front or behind another object with respect to a given viewpoint, which is typically the screen of the graphic display. If the pixel being scan converted in the rasterization process is closer to the viewer than the current values in the buffers, then the new pixel's color and depth values replace the old values in the frame buffer and z-buffer. The result is that with opaque objects, a first opaque object behind a second opaque object will not be rendered since the first opaque object would be hidden by the second opaque object when viewed from the front of the screen. This methodology breaks down, however, with transparent objects. Even if a transparent object is in front of another transparent object or an opaque object, the components of both will need to be blended for rendering.
Visible surface list priority algorithms determine a visibility ordering of objects in a scene. Objects in a scene are sorted, typically by their z-values, and then sent to the frame buffer in sort order. A correct image results if objects are rendered in this sorted order.
Visible surface list priority algorithms have been adapted to incorporate transparent objects. An example is the Painter's Algorithm, which is a depth sort algorithm. Utilizing the z-buffer to hold a depth value for each object, objects are rasterized and sorted in a back to front order. Where an object's z-value overlaps with another object's z-value, ambiguities are resolved by recursively splitting objects into parts and sorting the parts in back to front order based on z-values. Finally, pixel values for each object or part of an object are sent to the frame buffer in the established back to front order.
The problem of introducing transparent objects into such algorithms has been addressed in several ways. In the screen-door transparency method, only some of the pixels associated with a transparent object are utilized, creating a mesh. The bits associated with a pixel's (x, y) address are used to index a transparency bit mask. If the indexed bit of the mask is 1, the pixel is utilized. If not, the pixel is not utilized, and the next lowest object at that pixel location is utilized instead. The fewer 1 bits in the bit mask, the more transparent the object will appear. With this approach, there is no blending of color values. The aggregation over a number of pixels of the bit mask effect allows the viewer's eyes to perform spatial integration to produce an interpolated transparency. However, this method does not produce a quality image and it is not very pleasing to the eye.
Another approach utilizes a blending methodology. Each pixel of each object in a scene has an alpha value ranging from 0 to 1. An alpha value of 0 for a pixel indicates that the pixel is totally opaque, whereas an alpha value of 1 indicates that the pixel is totally transparent. The shade of a screen pixel that represents a view through one or more transparent surfaces, or an opaque surface and one or more transparent surfaces, is linearly interpolated from the individual shades of the surfaces themselves. To obtain the most correct result, the blending should take place in a strict back to front order. If this back to front order is not followed, the result will be a wrong color on a shape or portion of an object in the scene.
Another approach is to render transparent objects in a scene last, combining their colors with the colors already in the frame buffer. However, because the z-buffer is not modified in this method, when two transparent objects overlap, their depth in relation to each other is not taken into account. If they are rendered in front to back order, instead of back to front, the result will be incorrect colors.
Still another method of rendering transparent objects in a proper back to front order in z-buffer-based systems involves multiple rendering passes and increased memory. First, all opaque objects are rendered using the z-buffer. Then, transparent objects are processed into a separate set of buffers that contain an alpha value, color, z-value, and a flag bit, which is initially set to off. Then z-values are compared. If the pixel for a transparent object has a z-value closer to the viewer than the z-value in the opaque z-buffer, but more distant than the z-value in the transparent z-buffer, then the flag bit is set and the color, z-value and transparency are saved in the transparent buffers. This procedure is followed for all transparent objects. Then, the information for the most distant transparent object is blended with that in the original frame buffer and z-buffer. The transparency z-value of a flagged pixel replaces that in the opaque z-buffer and the flag bit is reset. This process is repeated to render the next closest object at each pixel until done.
Utilizing such a strict back to front ordering method, however, is very expensive with respect to machine requirements and the time it takes to render objects in a scene. The hardware costs may be prohibitive for some applications. Also, the time required to render the scene may be unacceptable to a user, such as in CAD/CAM applications, where a scene must be rendered and updated quickly to maintain user interactivity and productivity.
Another problem encountered in rendering transparent objects, besides the order individual objects are rendered, is the way in which the individual transparent object itself is processed. For example, to render a transparent three dimensional object, such as a sphere, the sphere is broken down into a series of polygons, referred to in the art as primitives, which are processed from primitive to primitive around the entire sphere. Each primitive has a surface normal pointing outward from a surface of the primitive. The problem is, as the primitives are traversed around the sphere, they are processed in a front to back order for one-half of the sphere, but in the opposite order for the second half of the sphere. This produces an incorrect color in the buffer, which results in a visual flaw. Instead of a smooth surface, the object has a break in appearance due to the correct and incorrect ordering for each half of the sphere.
It is thus apparent that there is a need in the art for an improved method of rendering transparent objects for graphic display which produces a higher quality image at a speed that is acceptable to the user for the given application and that does not require increased expense in the hardware necessary to run the application. There is also a need to process individual transparent objects in a back to front order to eliminate surface anomalies. The present invention meets these and other needs in the art.